<script>
import edit from "@/components/ProductSale/edit.vue";
import {getPurchaseIncomingByID} from "@/api/purchaseIncoming";
import {mapGetters} from "vuex";

export default {
  name: 'purchase_incoming',
  components: {edit},
  data() {
    return {
      formData: null,
      add: false,
      loading: false,
    }
  },
  mounted() {
    console.log(this.$route, "17");
    if (this.$route.params._pid) {
      this.loading = true;
      console.log(this.$route.params._pid, 17, this.formDataList);
      getPurchaseIncomingByID({
        _id: this.$route.params._pid,
      }).then(res => {
        console.log(res);
        if (res.data.data && res.data.data[0]) {
          this.formData = res.data.data[0];
          this.formData['notDialog'] = true;
          this.$nextTick(() => {
            this.loading = false;
          });
        }

        if (!this.formData) {
          console.log("缺少参数");
          // let view = this.$route;
          // this.$store.dispatch('tagsView/delView', view).then(({ visitedViews }) => {
          //   if (this.isActive(view)) {
          //     this.toLastView(visitedViews, view)
          //   }
          // });
          // this.$message.error("详情页缺少参数");
          // this.$router.push("/stock_manager/purchase_incoming");
        }
      });
    } else {


      this.add = true;
    }
  },
}
</script>

<template>
  <div v-loading="loading"
       style="height: 100%;">
    <edit v-if="add || formData"
          :formData="formData"/>
  </div>
</template>

<style>

</style>
